
package at.fhj.ase.clientarch.common;

import java.io.Serializable;

import at.fhj.ase.clientarch.common.util.StringUtil;

/**
 * Class representing a user accepting {@link String} instances of <code>username</code> and <code>password</code>.
 * <p>
 * Note that variables <strong>cannot</strong> be modified after instantiation at all.<br>
 * Note also that both instances must <strong>not</strong> be null and also have to have a {@link String#length()} > 0, otherwise an
 * {@link IllegalArgumentException} is thrown.
 * 
 * @author cja, sfe | www.fh-joanneum.at | Client Architectures and Design
 */
public final class User implements Serializable {
  private static final long serialVersionUID = 827297971827948113L;

  /* User credential properties (the password MUST be stored in a hashed/encrypted way) */
  private final String username;
  private final String password;

  public User(final String username, final String password) {
    this.username = StringUtil.checkEmptyOrNull(username);
    this.password = StringUtil.checkEmptyOrNull(password);
  }

  public String getUsername() {
    return username;
  }

  public String getPassword() {
    return password;
  }

  @Override
  public String toString() {
    return "User: " + username + ", pw: " + password;
  }
}
